package logic

import (
	"context"
	"shop/models/mysql"

	"shop/shoprpc/internal/svc"
	"shop/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopShowLogic {
	return &ShopShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShopShowLogic) ShopShow(in *shoprpc.ShopShowRequest) (*shoprpc.ShopShowResponse, error) {
	// todo: add your logic here and delete this line
	var shop mysql.Shop
	mysql.DB.Debug().Where("id=?", in.ShopId).Find(&shop)
	return &shoprpc.ShopShowResponse{
		Name:   shop.Name,
		Price:  float32(shop.Price),
		Number: int64(shop.Number),
	}, nil
}
